<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<title>康维信用户注册</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<!-- name="viewport" 的详细用法  http://www.php100.com/html/webkaifa/HTML5/2012/0831/10979.html -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="/favicon.ico" type="image/x-icon" rel="shortcut icon">
<!-- 
width - viewport的宽度 height - viewport的高度
initial-scale - 初始的缩放比例
minimum-scale - 允许用户缩放到的最小比例
maximum-scale - 允许用户缩放到的最大比例
user-scalable - 用户是否可以手动缩放
 -->
<link rel="stylesheet" href="${ctx}/notebook/notebook_files/font.css" type="text/css">
<link rel="stylesheet" href="${ctx}/notebook/notebook_files/app.v1.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/lanyuan.css" type="text/css">
<!-- base start 重要部分不可删改-->
<script type="text/javascript" src="${ctx}/notebook/notebook_files/app.v1.js"></script>
<script type="text/javascript" src="${ctx}/notebook/notebook_files/app.plugin.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.form.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery-validation/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery-validation/messages_cn.js"></script>
<script type="text/javascript" src="${ctx}/js/layer-v1.9.2/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/common/common.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/underscore.js"></script>
<script type="text/javascript" src="${ctx}/common/lyGrid.js"></script>
<script type="text/javascript" src="${ctx}/notebook/notebook_files/bootstrap-filestyle.min.js"></script>
<!--[if lt IE 9]> <script src="${ctx}/js/jquery/ie/html5shiv.js"></script> <script src="${ctx}/js/jquery/ie/respond.min.js"></script><![endif]-->
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<link href="${ctx}/js/date/bootstrap.min.css" rel="stylesheet">
<link href="${ctx}/js/date/font-awesome.min.css" rel="stylesheet">
<style type="text/css">
html {
    background-color: #fff;
}
.l_err{
    background: none repeat scroll 0 0 #FFFCC7;
    border: 1px solid #FFC340;
    font-size: 12px;
    padding: 4px 8px;
    width: 200px;
    display: none;
}
.error{
  border: 3px solid #FFCCCC;
}
.form-group{
  padding-left: 15px
}
.left{
	text-align: left;
	padding-left: 10px;
}
.right{
	text-align: right;
}
.hidden-xs{
	display: inherit;
}

.col-sm-3 {
	width: 20%;
	float: left;
}

.col-sm-9 {
	width: 80%;
	float: left;
	text-align: left;
}

label[class^="btn btn-default"] {
	margin-top: -4px;
}
</style>
<script type="text/javascript">
layer.config({
    extend: ['skin/style.css'], //加载新皮肤
    fix : false,// 用于设定层是否不随滚动条而滚动，固定在可视区域。
    skin: 'layer-ext-myskin' //一旦设定，所有弹层风格都采用此主题。
});
wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: '${jssdk.appid}', // 必填，公众号的唯一标识
    timestamp: '${jssdk.timestamp}', // 必填，生成签名的时间戳
    nonceStr: '${jssdk.nonceStr}', // 必填，生成签名的随机串
    signature: '${jssdk.signature}',// 必填，签名，见附录1
    jsApiList: ['closeWindow'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});
var rootPath = "${ctx}";
</script>
</head>
<body>
	<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
	<c:if test="${weixinUser.isReg eq 1}">
	<script type="text/javascript">
		wx.ready(function(){
			layer.alert("您已注册,请不要重复注册！",function(){
				wx.closeWindow();
			});
		});
	</script>
	</c:if>
	<c:if test="${weixinUser.isReg eq 0}">
	<form id="form" name="form" class="form-horizontal" method="post" action="${ctx}/weixin/save.shtml">
		<section class="panel panel-default">
		<div class="panel-body">
			<div class="form-group">
				
				<div class="col-sm-3">
					<label class="control-label">省份</label>
				</div>
				<div class="col-sm-9">
					<input type="hidden" value="${weixinUser.id}" name="weixinUserFormMap.id" id="id">
					<input type="hidden" value="1" name="weixinUserFormMap.isReg" id="isReg">
					<select name="weixinUserFormMap.provinceName" class="form-control">
						<c:forEach var="record" items="${province }">
							<option value="${record.provinceName }" pid="${record.id }" ${weixinUser.provinceName eq record.provinceName ? 'selected' : '' }>${record.provinceName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">城市</label>
				</div>
				<div class="col-sm-9">
					<select name="weixinUserFormMap.cityName" class="form-control">
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">医院</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入医院名" name="weixinUserFormMap.hospitalName" id="hospitalName" value="${weixinUser.hospitalName}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">姓名</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入姓名" name="weixinUserFormMap.doctorName" id="doctorName" value="${weixinUser.doctorName}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">科室</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入所属科室" name="weixinUserFormMap.hospitalDept" id="hospitalDept" value="${weixinUser.hospitalDept}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">等级</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入医生等级" name="weixinUserFormMap.doctorGrade" id="doctorGrade" value="${weixinUser.doctorGrade}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">职称</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入医生职称" name="weixinUserFormMap.doctorTitle" id="doctorTitle" value="${weixinUser.doctorTitle}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">邮箱</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入邮箱" name="weixinUserFormMap.email" id="email" value="${weixinUser.email}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">手机</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入手机" name="weixinUserFormMap.mobile" id="mobile" value="${weixinUser.mobile}">
				</div>
			</div>
		</div>
		<footer class="panel-footer text-right bg-light lter">
		<button type="submit" class="btn btn-success btn-s-xs">提交</button>
		</footer>
		</section>
	</form>
	</c:if>
</body>
<script type="text/javascript">
$(function() {
	// 异步加载所有菜单列表
	$("form").validate({
		submitHandler : function(form) {// 必须写在验证前面，否则无法ajax提交
			ly.ajaxSubmit(form,{//验证新增是否成功
				type : "post",
				dataType : "json",
				success : function(data) {
					if (data == "success") {
						layer.alert("注册成功！",function(){
							wx.closeWindow();
						});
					} else {
						layer.alert('注册失败！'+ data);
					}
				}
			});
		},
		rules : {
			"weixinUserFormMap.doctorName" : {
				required : true,
			}
		},
		messages : {
			"weixinUserFormMap.doctorName" : {
				required : "姓名不能为空"
			}
		},
		errorPlacement : function(error, element) {// 自定义提示错误位置
			$(".l_err").css('display', 'block');
			$(".l_err").html(error.html());
		},
		success : function(label) {// 验证通过后
			$(".l_err").css('display', 'none');
		}
	});
	$("select[name='weixinUserFormMap.provinceName']").change(function(){
		var data = CommnUtil.ajax("${ctx}/region/loadCityByProvinceId.shtml",{'provinceId':$("select[name='weixinUserFormMap.provinceName'] option:checked").attr("pid")},"json");
		$("select[name='weixinUserFormMap.cityName']").empty();
		$.each(data,function(i,e){
			$("select[name='weixinUserFormMap.cityName']").append("<option value='" + e.cityName + "'>" + e.cityName + "</option>")
		});
	});
	$("select[name='weixinUserFormMap.provinceName']").change();
	$("select[name='weixinUserFormMap.cityName']").val("${weixinUser.cityName}");
});
</script>
</html>